<!--  -->
<template>

    <div>多文件上传

        {{ fileList }}
        <el-upload :headers="headers" v-model:file-list="fileList" class="upload-demo" :action="uploadUrl"
            list-type="picture">

            <el-button>选择文件</el-button>
        </el-upload>

        <el-button @click="submit">提交</el-button>
    </div>
</template>

<script lang='ts' setup>

import { useUserStore } from '../../store/user';
import { reactive, toRefs, ref, onMounted } from 'vue'
import type { UploadProps, UploadUserFile } from 'element-plus'
const uploadUrl = import.meta.env.VITE_BASE_URL + 'upload/add'
const imgUrl = import.meta.env.VITE_IMG_URL
const store = useUserStore();

const fileList = ref<any>([])

const headers = { Authorization: store.token }

//根据id返回门店信息

const getData = (id: number) => {

    //调接口
    let data = {
        "errCode": 10000,
        "errMsg": "请求成功",
        "data": {
            "id": 1,
            "name": "天津包子",
            "mobile": "13522568990",
            "pass": null,
            "tel": "13522568990",
            "logo": "2021/10/22/202110221150137894894.jpg",
            "address": "巩华新村5区四栋",
            "startTime": "8:30",
            "endTime": "21:30",
            "services": "早点美食",
            "username": "张三",
            "intro": "\r\n狗不理包子（Go Believe/Goubuli steamed bun）是中国天津的一道闻名中外的传统小吃，该小吃以一道由面粉、猪肉等材料制作而成的小吃，其始创于公元1858年（清朝咸丰年间），有100多年历史，该小吃为“天津三绝”之首，是中华老字号之一",
            "images": [
                {
                    "id": 2,
                    "storeid": 1,
                    "url": "2024/09/06/202409062059486314660.png"
                },
                {
                    "id": 1,
                    "storeid": 1,
                    "url": "2024/09/06/202409062058300908303.jpeg"
                }
            ]
        }
    }

    fileList.value = data.data.images.map((item: any) => ({ name: item.url, url: imgUrl + item.url }));


    console.log(fileList.value);





}

onMounted(() => {
    getData(100);
})

const submit = () => {

    let images = fileList.value.map((item: any) => ({
            ur: item.response ? item.response.data : item.name
        })
    )

    console.log(1111111111, images);

}



</script>
<style scoped></style>